docs: Improve the GtkVideo gallery image
authorMatthias Clasen <mclasen@redhat.com>
Mon, 26 Oct 2020 02:17:15 +0000 (22:17 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 26 Oct 2020 02:17:15 +0000 (22:17 -0400)
docs/reference/gtk/images/video.png
docs/tools/shooter.c
docs/tools/widgets.c
docs/tools/widgets.h

index c044c80058c9d4c4a793f9d69e8694b42aaa1620..4230baaaa44bfeb0c7cfab5c2c641752418c8d83 100644 (file)
Binary files a/docs/reference/gtk/images/video.png and b/docs/reference/gtk/images/video.png differ
index bf72d1e4716866ea5ee86a2e5d270f180f041322..ff81d44e1f9046b5b3f34c20ab3c1ccc6f7fce8a 100644 (file)
@@ -117,6 +117,13 @@ snapshot_widget (GtkWidget *widget)
   return surface;
 }
 
+static gboolean
+quit_cb (gpointer data)
+{
+  *(gboolean *)data = TRUE;
+  return G_SOURCE_REMOVE;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -144,7 +151,15 @@ main (int argc, char **argv)
                                      NULL);
         }
 
-      //while (1) g_main_context_iteration (NULL, 1);
+      if (info->wait > 0)
+        {
+          gboolean quit = FALSE;
+
+          g_timeout_add (info->wait, quit_cb, &quit);
+
+          while (!quit)
+            g_main_context_iteration (NULL, TRUE);
+        }
 
       surface = snapshot_widget (info->window);
 
index 068ef81f432e865ab8a3a26b168ca8b607c32178..96b9b6254c1cdaf2d6bb22237cbb43eb7213c45d 100644 (file)
@@ -1099,10 +1099,13 @@ create_video (void)
 {
   GtkWidget *widget;
   GtkWidget *vbox;
+  WidgetInfo *info;
 
-  widget = gtk_video_new_for_filename ("../../demos/gtk-demo/gtk-logo.webm");
-  gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
-  gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
+  widget = gtk_video_new_for_filename ("demos/gtk-demo/gtk-logo.webm");
+  gtk_video_set_autoplay (GTK_VIDEO (widget), TRUE);
+
+  gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
+  gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
 
   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
   gtk_box_append (GTK_BOX (vbox), widget);
@@ -1110,7 +1113,10 @@ create_video (void)
 
   add_margin (vbox);
 
-  return new_widget_info ("video", vbox, SMALL);
+  info = new_widget_info ("video", vbox, MEDIUM);
+  info->wait = 2000;
+
+  return info;
 }
 
 static WidgetInfo *
index 2e337038d6b93ffc288a613b9b792f035ae541b7..99e0d4a1fabc887b8286e401b57590f42313c581 100644 (file)
@@ -18,6 +18,7 @@ typedef struct WidgetInfo
   char *name;
   gboolean no_focus;
   gboolean include_decorations;
+  guint wait;
   WidgetSize size;
 } WidgetInfo;